#include "stdafx.h"
#include "FormHwnd.h"
#include "IOptionsControl.h"

::HWND CFormHwnd::GetMainFormHwnd()
{
	int iRetVal = NULL;
	return ValueSet().GetValue(MAIN_FORM, iRetVal) ? (::HWND)iRetVal : NULL;
}

void CFormHwnd::SetMainFormHwnd(::HWND ptrFormHwnd)
{
	ValueSet().SetValue(MAIN_FORM, (int)ptrFormHwnd);
}

::HWND CFormHwnd::GetSubjectMonitorFormHwnd()
{	
	int iRetVal = NULL;
	return ValueSet().GetValue(SUBJECT_MONITOR_FORM, iRetVal) ? (::HWND)iRetVal : NULL;
}

void CFormHwnd::SetSubjectMonitorFormHwnd(::HWND ptrFormHwnd)
{
	ValueSet().SetValue(SUBJECT_MONITOR_FORM, (int)ptrFormHwnd);
}

::HWND CFormHwnd::GetSubjectOrderMathingFormHwnd()
{
	int iRetVal = NULL;
	return ValueSet().GetValue(SUBJECT_ORDER_MATHING_FORM, iRetVal) ? (::HWND)iRetVal : NULL;
}

void CFormHwnd::SetSubjectOrderMathingFormHwnd(::HWND ptrFormHwnd)
{
	ValueSet().SetValue(SUBJECT_ORDER_MATHING_FORM, (int)ptrFormHwnd);
}

::HWND CFormHwnd::GetContractFormHwnd(void * ptrContract)
{
	::HWND hRetVal = NULL;
	int iRetVal = NULL;
	IContract * ptrCon = reinterpret_cast<IContract *>(ptrContract);
	if (!ptrCon) goto __end;
	if (!ValueSet().GetValue(ptrCon->GetOptCode(), iRetVal)) goto __end;
	hRetVal = (::HWND)iRetVal;
__end:
	return hRetVal;
}

void CFormHwnd::SetContractFormHwnd(void * ptrContract, ::HWND ptrFormHwnd)
{
	IContract * ptrCon = reinterpret_cast<IContract *>(ptrContract);
	if (!ptrCon) goto __end;
    ValueSet().SetValue(ptrCon->GetOptCode(), (int)ptrFormHwnd);
__end:
	return;
}

::HWND CFormHwnd::GetChildHwnd(::HWND hParent, int iId)
{
	::HWND hRetVal = NULL;
    if (!hParent) goto __end;
    hRetVal = ::GetDlgItem(hParent, iId);
__end:
	return hRetVal;
}

void CFormHwnd::SetRiskInfoFormHwnd(::HWND ptrFormHwnd)
{
    ValueSet().SetValue("RiskInfoForm", (int)ptrFormHwnd);
}

::HWND CFormHwnd::GetRiskInfoFormHwnd()
{
	int iRetVal = NULL;
	return ValueSet().GetValue("RiskInfoForm", iRetVal) ? (::HWND)iRetVal : NULL;
}

void CFormHwnd::SetFastQuoteFormHwnd(::HWND ptrFormHwnd)
{
    ValueSet().SetValue("UiFastQuoteForm", (int)ptrFormHwnd);
}

::HWND CFormHwnd::GetFastQuoteFormHwnd()
{
	int iRetVal = NULL;
	return ValueSet().GetValue("UiFastQuoteForm", iRetVal) ? (::HWND)iRetVal : NULL;
}

void CFormHwnd::SetPreviewRiskFormHwnd(::HWND ptrFormHwnd)
{
    ValueSet().SetValue("PreviewRiskForm", (int)ptrFormHwnd);
}

::HWND CFormHwnd::GetPreviewRiskFormHwnd()
{
	int iRetVal = NULL;
	return ValueSet().GetValue("PreviewRiskForm", iRetVal) ? (::HWND)iRetVal : NULL;
}

void CFormHwnd::SetEntTrdFormHwnd(::HWND ptrFormHwnd)
{
    ValueSet().SetValue("EntTrdForm", (int)ptrFormHwnd);
}
::HWND CFormHwnd::GetEntTrdFormHwnd()
{
	int iRetVal = NULL;
	return ValueSet().GetValue("EntTrdForm", iRetVal) ? (::HWND)iRetVal : NULL;
}